package com.zy.explore.sys.infrastructure.runner;

import com.zy.explore.sys.application.service.DingTalkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * description 缓存部门树随系统启动开始缓存
 *
 * @author 🇨🇳中国印🇨🇳
 * @date 2021年07月11日 02:22
 */
@Slf4j
@Component
public class CacheDeptTreeRunner implements ApplicationRunner {

    @Resource
    private DingTalkService dingTalkService;

    @Override
    public void run(ApplicationArguments args) {
        Boolean cached = dingTalkService.cacheDeptTree(1L);
        if (cached) {
            log.info("部门树随系统启动而缓存成功");
        } else {
            log.error("部门树随系统启动而缓存失败");
        }
    }
}
